<?php

	session_start();

	require_once("appconf.php");
	require_once("lib/utility.php");
	require_once("lib/class.Report.php");

	require_once("output_includes.php");

	if(!isset($_SESSION['username'])) {
		header("HTTP/1.1 401 Unauthorized");
		die();
	}


	$reportObj 	= new Report($_SESSION['username'], $_REQUEST["file"]);
	$type		= $_REQUEST["type"];

	$outputObj = Registry::getByName("output", $type);
	if ($outputObj) {
		$outputObj->write($reportObj);
	} else {
		header("HTTP/1.1 501 Not Implemented");
		echo "Format not supported yet.";
	}

?>